﻿<Window x:Class="DataInterpolator.View.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:util="clr-namespace:Common.Utility;assembly=Common"
      xmlns:view="clr-namespace:DataInterpolator.View"
      xmlns:p="clr-namespace:DataInterpolator.Properties"
      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
      xmlns:command="http://www.galasoft.ch/mvvmlight"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:ignore="http://www.galasoft.ch/ignore" mc:Ignorable="d ignore"
      d:Height="396.632" d:Width="363.158" WindowStartupLocation="Manual"
      Height="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Height, Mode=TwoWay}"
      Width="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Width, Mode=TwoWay}"
      Left="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Left, Mode=TwoWay}"
      Top="{Binding Source={x:Static p:Settings.Default}, Path=MainWindowSize.Top, Mode=TwoWay}"
      Title="Data Interpolator"
      DataContext="{Binding Main, Source={StaticResource Locator}}" d:DesignWidth="1000"
      d:DesignHeight="569">
   <Window.InputBindings>
      <KeyBinding Key="O" Modifiers="Control"
            Command="{Binding OpenFileDialogCommand, Mode=OneWay}" />
      <KeyBinding Key="R" Modifiers="Control"
            Command="{Binding LoadInputFileCommand, Mode=OneWay}" />
      <KeyBinding Key="S" Modifiers="Control"
            Command="{Binding SaveOutputDataCommand, Mode=OneWay}" />
      <KeyBinding Key="Q" Modifiers="Control" Command="{Binding ExitCommand, Mode=OneWay}" />
      <KeyBinding Key="F5" Command="{Binding RefreshPlotCommand, Mode=OneWay}" />
      <KeyBinding Key="Z" Command="{Binding UndoCommand, Mode=OneWay}" Modifiers="Ctrl" />
      <KeyBinding Key="Y" Command="{Binding RedoCommand, Mode=OneWay}" Modifiers="Ctrl" />

   </Window.InputBindings>
   <i:Interaction.Triggers>
      <i:EventTrigger EventName="Closing">
         <command:EventToCommand Command="{Binding ClosingCommand}"
               PassEventArgsToCommand="True" />
      </i:EventTrigger>
   </i:Interaction.Triggers>
   <DockPanel HorizontalAlignment="Stretch" Height="Auto" LastChildFill="True"
         Grid.RowSpan="2" VerticalAlignment="Stretch" Width="Auto">
      <Menu Grid.RowSpan="2" VerticalAlignment="Top" DockPanel.Dock="Top">
         <MenuItem Header="File">
            <MenuItem Header="Export Interpolation Data"
                  Command="{Binding ShowExportInterpolationCommand, Mode=OneWay}" />
            <MenuItem Header="Exit" InputGestureText="Ctrl+Q"
                  Command="{Binding ExitCommand, Mode=OneWay}" />
         </MenuItem>
         <MenuItem Header="Edit">
            <MenuItem Header="Undo" Command="{Binding UndoCommand, Mode=OneWay}"
                  InputGestureText="Ctrl+Z" />
            <MenuItem Header="Redo" Command="{Binding RedoCommand, Mode=OneWay}"
                  InputGestureText="Ctrl+Y" />
         </MenuItem>
         <MenuItem Header="View">
            <MenuItem Header="Show Database Viewer"
                  Command="{Binding ShowDatabaseViewerCommand, Mode=OneWay}" />
            <MenuItem Header="Refresh Plot" InputGestureText="F5"
                  Command="{Binding RefreshPlotCommand, Mode=OneWay}" />
         </MenuItem>
      </Menu>
      <Grid x:Name="LayoutRoot" Margin="5">
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
         </Grid.ColumnDefinitions>
         <view:WellListView Grid.RowSpan="2" />
         <GroupBox Header="Options" VerticalAlignment="Top" Grid.Column="1">
            <Grid>
               <Grid.RowDefinitions>
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="*" />
               </Grid.RowDefinitions>
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="Auto" />
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="0" />
                  <ColumnDefinition Width="Auto" />
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="0" />
               </Grid.ColumnDefinitions>
               <TextBlock Text="Zero Reference" TextTrimming="CharacterEllipsis"
                     Padding="3" Margin="3" Height="23" VerticalAlignment="Top" />
               <ComboBox VerticalAlignment="Top" Grid.Column="1" Padding="3" Margin="3"
                     HorizontalContentAlignment="Stretch"
                     ItemsSource="{Binding ZeroReferenceOptions}" Grid.ColumnSpan="5">
                  <i:Interaction.Behaviors>
                     <util:CancellableSelectionBehavior
                           SelectedItem="{Binding ZeroReferenceChoice}" />
                  </i:Interaction.Behaviors>
               </ComboBox>
               <TextBlock Text="Window Start" TextTrimming="CharacterEllipsis" Padding="3"
                     Margin="3" Height="23" VerticalAlignment="Top" Grid.Row="1" />
               <TextBox Height="23" Padding="3" Margin="3" TextWrapping="Wrap"
                     VerticalAlignment="Top"
                     Text="{Binding WindowStart, UpdateSourceTrigger=Explicit}"
                     Grid.Column="1" Grid.Row="1" HorizontalContentAlignment="Stretch"
                     IsEnabled="{Binding WindowStartEnabled}"
                     util:InputBindingsManager.UpdateOnEnter="TextBox.Text" />
               <ComboBox VerticalAlignment="Top" Grid.Column="2" Padding="3" Margin="3"
                     HorizontalContentAlignment="Stretch"
                     ItemsSource="{Binding WindowOptions}"
                     SelectedValue="{Binding WindowStartChoice}" Grid.Row="1" Width="75" />
               <TextBlock Text="Window End" TextTrimming="CharacterEllipsis" Padding="3"
                     Margin="3" Height="23" VerticalAlignment="Top" Grid.Column="3"
                     Grid.Row="1" />
               <TextBox Height="23" Padding="3" Margin="3" TextWrapping="Wrap"
                     VerticalAlignment="Top"
                     Text="{Binding WindowEnd, UpdateSourceTrigger=Explicit}"
                     Grid.Column="4" Grid.Row="1" IsEnabled="{Binding WindowEndEnabled}"
                     util:InputBindingsManager.UpdateOnEnter="TextBox.Text" />
               <ComboBox VerticalAlignment="Top" Grid.Column="5" Padding="3" Margin="3"
                     HorizontalContentAlignment="Stretch"
                     ItemsSource="{Binding WindowOptions}"
                     SelectedValue="{Binding WindowEndChoice}" Grid.Row="1" Width="75" />
            </Grid>
         </GroupBox>
         <TabControl Grid.Column="1" Grid.Row="1" TabStripPlacement="Bottom" Margin="5">
            <TabItem Header="Iso Plots">
               <view:IsoPlotsView />
            </TabItem>
            <TabItem Header="Interpolation">
               <view:InterpolationView />
            </TabItem>
         </TabControl>
      </Grid>
   </DockPanel>
</Window>
